package com.yxhl.zoume.domain.interactor.car.specialcar;

import com.google.protobuf.GeneratedMessageV3;
import com.yxhl.protobuf.BizOrderRequest;
import com.yxhl.protobuf.BizOrderResponse;
import com.yxhl.zoume.data.http.repository.car.SpecialCarRepository;
import com.yxhl.zoume.domain.DomainConstants;

import javax.inject.Inject;
import javax.inject.Named;

import rx.Observable;
import rx.Scheduler;

/**
 * Created by sugarya on 16/4/9.
 */
public class GetSpecialCarOrderUseCase extends com.yxhl.zoume.domain.interactor.base.ProtoUseCase<BizOrderResponse> {

    private SpecialCarRepository specialCarRepository;

    @Inject
    public GetSpecialCarOrderUseCase(
            @Named(DomainConstants.UI_THREAD) Scheduler uiThread,
            @Named(DomainConstants.EXECUTOR_THREAD) Scheduler executorThread,
            SpecialCarRepository specialCarRepository) {
        super(uiThread, executorThread);
        this.specialCarRepository = specialCarRepository;
    }

    @Override
    protected Observable<BizOrderResponse> buildObservable(GeneratedMessageV3 message) {
        return specialCarRepository.getSpecialCarOrder((BizOrderRequest) message)
                .subscribeOn(executorThread)
                .observeOn(uiThread);
    }
}
